module.exports = function ($scope, $resource, toaster, $stateParams, $modal, FileUploader,$interval, $modalInstance) {
    $scope.canClick=false;  
    $scope.description = "获取验证码";  
    var second=59;  
    var timerHandler;  
    $scope.getTestCode = function(){  
        timerHandler = $interval(function(){  
            if(second<=0){  
                $interval.cancel(timerHandler);    //当执行的时间59s,结束时，取消定时器 ，cancle方法取消   
                second=59;  
                $scope.description="获取验证码";  
                $scope.canClick=false;    //因为 ng-disabled属于布尔值，设置按钮可以点击，可点击发送  
            }else{  
                $scope.description=second+"s后重发";  
                second--;  
                $scope.canClick=true;  
            }  
        },1000)   //每一秒执行一次$interval定时器方法  
    };  
    $scope.info = {};

    $scope.getInfo = function(){
        $resource('/api/as/mc/useraccount/getUserAccountForShop', {}, {}).save({}, function (res) {
            if (res.errcode === 0) {
                console.log(res);
                $scope.obj = res.data;
            } else {
                toaster.error({ title: '', body: res.errmsg });
            }
        });
    }
    $scope.getInfo();
    $scope.ok = function(){
        if (confirm('确定要提现吗?')){
            if ($scope.info.track_price < 0){
              alert('提现金额不能为负数');
            } else{
              $resource('/api/ac/mc/merchantUserAccountService/createGetMoneyForShop', {}, {}).save({'track_price' : $scope.info.track_price * 100}, function (res) {
                  if (res.errcode === 0) {
                      console.log(res);
                      toaster.success({ title: '', body: '提现成功'});
                      $modalInstance.close();
                  } else {
                      toaster.error({ title: '', body: res.errmsg });
                  }
              });
            }
        }
       
    }

};